<div class="attachments index">    
    
    <?php    
    $nodeTitle = '';    
    if (isset($node['Node']['title'])) {
	$nodeTitle = $node['Node']['title'];
    }    
    ?>
    <div class="floatl">
	<h2><?php echo $title_for_layout;?></h2>    
    </div>
    
    <?php
	$formUrl = array('controller' => 'attachments', 'action' => 'index');
        if (isset($this->params['named']['editor'])) {
            $formUrl['editor'] = 1;
        }	
	
	if (isset($this->params['named']['image'])) {
            $formUrl['image'] = 1;
        }
	
	echo $this->Form->create(null, array('url' => $formUrl));
	echo $this->Form->input('node_id', array (
	    'type' => 'select',
	    'label' => false,
	    'selected' => $nodeId ? $nodeId : 0,
	    'div' => array('class' => 'floatr'),
	    'onchange' => 'this.form.submit()'
	));
	echo $this->Form->end();
    ?>
    
    <div class="clearer"></div>
    
    <fieldset>
	<div class="tabs">
                <ul>
		    <?php
		    // display file selection only if we are not called from the editor with the image parameter
		    if (! (isset($this->params['named']['editor']) && isset($this->params['named']['image']))) {
		    ?>
			<li><a href="#manage-files"><span><?php __('Files'); ?></span></a></li>		    
		    <?php
		    }
		    ?>			
		    <li><a href="#manage-images"><span><?php __('Images'); ?></span></a></li>
                </ul>
	    
		<?php
		if (! (isset($this->params['named']['editor']) && isset($this->params['named']['image']))) {
		?>
		
		    <div id="manage-files">
			<?php
			    echo $this->element('admin/attachments/add-file');
			    echo $this->element('admin/attachments/manage-files');
			?>		    
		    </div>	
	    
		<?php
		}
		?>	    
		
		<div id="manage-images">
		    <?php
			echo $this->element('admin/attachments/add-image');
			echo $this->element('admin/attachments/manage-images');
		    ?>		    
		</div>	
	    	    
	</div>	   
</div>	